package com.huidu.bitrade.service;

import com.huidu.bitrade.dao.MemberProfileDao;
import com.huidu.bitrade.entity.MemberProfile;
import com.huidu.bitrade.service.Base.BaseService;
import org.apache.commons.collections4.CollectionUtils;
import org.springframework.beans.factory.annotation.Autowired;
import org.springframework.stereotype.Service;

import java.util.ArrayList;
import java.util.List;
import java.util.stream.Collectors;

@Service
public class MemberProfileService extends BaseService {

    @Autowired
    private MemberProfileDao memberProfileDao;

    /**
     * 获取被禁用的用户
     * @return
     */
    public List<Long> getForbidMember(){
        List<MemberProfile> list = memberProfileDao.findAllByAssetStatus(1);
        if(CollectionUtils.isEmpty(list)){
            return new ArrayList<>();
        }
        return list.stream().map(MemberProfile::getMemberId).collect(Collectors.toList());
    }

    /**
     * 判断是否被禁止交易
     */
    public boolean isForbid(Long memberId){
        List<Long> memberIds = getForbidMember();
        return memberIds.contains(memberId);
    }


}
